<template>
  <div>
      <el-row style="background-color: white;">
        <el-col>
            <el-button type="primary" class="back" @click="$router.back(-1)">返回</el-button>
          </el-col>
          <el-col style="margin: 0px 10%; width: 80%;">
            <p style="text-align: center; font-size: 30px;">高校党委理论学习中心组</p>
            <el-form :model="form" :rules="rules" ref="form" style="font-weight: 600;" >
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="学校" prop="school">
                            <el-input style="width: 70%" v-model="form.sch_name"></el-input>
                          <!-- <el-select style="width: 80%" v-model="form.sch_name" placeholder="请选择学校" filterable >
                            <el-option v-for="item in schools" :key="item.sch_id" :label="item.sch_name" :value="item.sch_name"></el-option>
                          </el-select> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="学习时间" prop="datetime">
                          <el-input style="width: 70%" v-model="form.learn_time"></el-input>
                          <!-- <el-date-picker
                            v-model="form.learn_time"
                            type="datetime"
                            style="width: 80%"
                            >
                          </el-date-picker> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="学习次数" prop="learnNumbers">
                            <el-input
                              v-model="form.learn_year"
                              class="xiahuaxian"
                            >
                            </el-input>
                            年度第
                              <el-input
                              v-model="form.learn_num"
                              class="xiahuaxian"
                            >
                            </el-input>
                            次中心组学习
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="学习内容" prop="textcontent">
                            <el-input
                              type="textarea"
                              v-model="form.learn_content"
                              :maxlength='500'
                              show-word-limit
                              style="width: 85%"
                            >
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col>
                        <el-form-item label="学习形式" prop="studyway">
                            <el-checkbox-group v-model="form.learn_ways">
                              <el-checkbox :label="0">集体学习研讨</el-checkbox>
                              <el-checkbox :label="1">个人自学</el-checkbox>
                              <el-checkbox :label="2">专题调研</el-checkbox>
                              <el-checkbox :label="3">扩大会</el-checkbox>
                              <el-checkbox :label="4">其他</el-checkbox>
                              <el-input class="xiahuaxian" v-model="form.other1"></el-input>
                            </el-checkbox-group>
                        </el-form-item>
                    </el-col>
                    <el-col>
                        <el-form-item label="参加人员" prop="joinpeople">
                          <el-checkbox-group v-model="form.join_person">
                            <el-checkbox :label="0">校党委中心组成员</el-checkbox>
                            <el-checkbox :label="1">全体校领导</el-checkbox>
                            <el-checkbox :label="2">全体中层以上党员干部</el-checkbox>
                            <el-checkbox :label="3">各单位/部门主要负责人</el-checkbox>
                            <el-checkbox :label="4">副处级及以上干部</el-checkbox>
                            <el-checkbox :label="5">二级党组织书记</el-checkbox>
                            <el-checkbox :label="6">其他</el-checkbox>
                            <el-input :disabled="disabled2" class="xiahuaxian" v-model="form.other2"></el-input>
                          </el-checkbox-group>
                        </el-form-item>
                    </el-col>
                    <el-col>
                        <el-form-item label="相关新闻链接" prop="news">
                          <el-input v-model="form.newsurl" style="width: 85%;"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col>
                        <p style="color: #606266; font-size: 16px;">报告人非校党委中心组成员：</p>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="报告人" prop="speaker">
                            <el-input
                              type="textarea"
                              v-model="form.reporter"
                              :maxlength='20'
                              show-word-limit
                              style="width: 85%"
                            >
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="报告人职务/职称" prop="job">
                            <el-input
                              type="textarea"
                              v-model="form.reporter_career"
                              :maxlength='30'
                              show-word-limit
                              style="width: 85%"
                            >
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="备注" prop="remark">
                            <el-input
                              type="textarea"
                              v-model="form.remark"
                              :maxlength='100'
                              show-word-limit
                              style="width: 85%"
                            >
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col>
                        <p style="color: #606266; font-size: 16px;"> 附件：</p>
                    </el-col>
                    <el-col :span="24" class="Label">
                        <el-form-item label="学习方案:" prop="studyPlan">
                            <span>{{file2_name}}.pdf</span>
                           <el-button type="primary" style="margin-left: 20px;"> <a :href="uploadUrl2" style="color: #fff;" download="">点击下载</a></el-button>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="Label">
                        <el-form-item label="学习记录:" prop="studyRecord">
                            <span>{{file3_name}}.pdf</span>
                           <el-button type="primary" style="margin-left: 20px;"><a :href="uploadUrl3" style="color: #fff;" download="">点击下载</a></el-button>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="Label">
                        <el-form-item label="学习报告:" prop="studyReport">
                            <span>{{file1_name}}.pdf</span>
                           <el-button type="primary" style="margin-left: 20px;">
                              <a :href="uploadUrl1" style="color: #fff;" download="pdf">点击下载</a></el-button>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="Label">
                        <el-form-item label="其他材料:" prop="otherFile">
                            <span>{{file4_name}}.pdf</span>
                           <el-button type="primary" style="margin-left: 20px;"><a :href="uploadUrl4" style="color: #fff;" download="">点击下载</a></el-button>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="24">
                      <el-form-item style="text-align: center; margin: 20px 0px;">
                          <el-button type="primary" @click="submitForm('form')">提交</el-button>
                          <el-button type="warning" @click="resetForm('form')">重置</el-button>
                          <el-button><a href="/uploads/file/20210728/ddb1b10fb92ef8360913c8d0842fd20e.pdf"></a></el-button>
                          <el-button>管理员登录</el-button>
                      </el-form-item>
                    </el-col> -->
                </el-row>
            </el-form>
          </el-col>
      </el-row>
  </div>
</template>

<script>
import btnGroup from '../../Common/btn-group.vue'
import http from '../../../assets/js/http'
export default {
  data() {
    return {
      form: {
        join_person: [],
        learn_content: '',
        learn_time: '',
        learn_ways: [],
        newsurl: '',
        sch_name: ''
      },
      schools: Lockr.get('schInfo'),
      fileList1: [],
      fileList2: [],
      fileList3: [],
      fileList4: [],
      mode: {},
      uploadUrl1: '',
      uploadUrl2: '',
      uploadUrl3: '',
      uploadUrl4: '',
      file_id1: '',
      file_id2: '',
      file_id3: '',
      file_id4: '',
      file1_name: '',
      file2_name: '',
      file3_name: '',
      file4_name: ''
    }
  },
  activated() {},
  watch: {},
  created() {
    this.init()
  },
  mounted() {},
  methods: {
    init () {
      this.getInfoById()
      console.log(this.schools)
    },
    getInfoById () {
      const data = {
        id: this.$route.params.id
      }
      this.apiPost('admin/Info/infoDetail', data).then((res) => {
        this.handelResponse(res, (data) => {
          console.log(this.form)
          this.form = res.data
          console.log(res.data)
          if (this.form.join_person[0] !== '') {
            this.form.join_person = this.form.join_person.map(Number)
          }
          if (this.form.learn_ways[0] !== '') {
            this.form.learn_ways = this.form.learn_ways.map(Number)
          }
          this.form.learn_time = res.data.learn_start_time + ' 至 ' + res.data.learn_end_time
          this.file_id1 = res.data.learn_baogao_file_id
          this.file_id2 = res.data.learn_fangan_file_id
          this.file_id3 = res.data.learn_jilu_file_id
          this.file_id4 = res.data.learn_other_file_id
          this.file1_name = res.data.file1_name
          this.file2_name = res.data.file2_name
          this.file3_name = res.data.file3_name
          this.file4_name = res.data.file4_name
          console.log(this.form)
          this.uploadFile1()
          this.uploadFile2()
          this.uploadFile3()
          this.uploadFile4()
        })
      })
    },
    uploadFile1 () {
    //   console.log(this.file_id1)
      this.uploadUrl1 = 'http://8.142.34.26:8096/php/index.php/admin/download/index?file_id=' + this.file_id1
    //   console.log(this.uploadUrl1)
    },
    uploadFile2 () {
      this.uploadUrl2 = 'http://8.142.34.26:8096/php/index.php/admin/download/index?file_id=' + this.file_id2
    //   console.log(this.uploadUrl2)
    },
    uploadFile3 () {
      this.uploadUrl3 = 'http://8.142.34.26:8096/php/index.php/admin/download/index?file_id=' + this.file_id3
    //   console.log(this.uploadUrl3)
    },
    uploadFile4 () {
      this.uploadUrl4 = 'http://8.142.34.26:8096/php/index.php/admin/download/index?file_id=' + this.file_id4
    //   console.log(this.uploadUrl3)
    }
  },
  mixins: [http],
  components: {
    btnGroup
  }
}
</script>

<style scoped>
.xiahuaxian {
  width: 100px;
  display: inline-block;
}
.xiahuaxian .el-input__inner {
  width: 100px;
  margin-left: 5px;
  border: 0;
  border-bottom: 1px solid #888;
  border-radius: 0;
}
.back {
  position: absolute;
  top: 10px;
  right: 10px;
}
</style>
